package com.qiandao.xuexitong.handler;

import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.handler.context.CellWriteHandlerContext;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;

public class AttendanceDataWriteHandler implements CellWriteHandler {
    
    private final AttendanceExportHandler exportHandler;
    
    public AttendanceDataWriteHandler(AttendanceExportHandler exportHandler) {
        this.exportHandler = exportHandler;
    }
    
    @Override
    public void afterCellDispose(CellWriteHandlerContext context) {
        Cell cell = context.getCell();
        // 获取当前单元格的值
        String cellValue = cell.getStringCellValue();
        
        // 检查是否是签到状态（迟到、已签到、缺勤、未签到）
        if (cellValue != null && (cellValue.equals("迟到") || cellValue.equals("已签到") || 
            cellValue.equals("缺勤") || cellValue.equals("未签到"))) {
            CellStyle style = exportHandler.getStatusStyle(cellValue);
            if (style != null) {
                cell.setCellStyle(style);
            }
        }
    }
} 